/**
 * @Author: lianghuan
 * @Description: response
 * @emoji - ( ゜- ゜)つロ 乾杯~
 * @email lianghuanA@outlook.com
 * @Date: 2021-10-12 13:35
 * @Version: 1.0.0
 */

package response

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func Response(ctx *gin.Context, httpStatus int, code int, data gin.H, msg string) {

	ctx.JSON(httpStatus, gin.H{
		"code": code,
		"data": data,
		"msg":  msg,
	})
}

func Ok(ctx *gin.Context, data gin.H, msg string) {
	Response(ctx, http.StatusOK, 200, data, msg)
}

func Fail(ctx *gin.Context, data gin.H, msg string) {
	Response(ctx, http.StatusOK, 400, data, msg)
}
